package session2.casting;

public class CastTest2 {
	public static void main(String[] args) {
		Animal a[] = { new Animal(), new Dog(), new Animal() };

		Animal animal = new Animal();
		for (int i = 0; i < a.length; i++) {
			animal.makeNoise();
			if (animal instanceof Dog) {
				// animal.playDead();//ERR: The method playDead() is undefined
				// for the type Animal
				// ((Dog) animal).playDead();//OK
				Dog d = (Dog) animal;//Casting the Reference variable;
				d.playDead();
			}
		}
	}
}